/*
 * acm1539.c
 *
 *  Created on: 28 Mar 2010
 *      Author: xuxu
 */

#include<stdio.h>

int calcu(int n)
{
	if(3==n)
		return 1;
	else if(n<3)
		return 0;
	else
		return calcu(n/2)+calcu(n-n/2);
}

int main()
{
	int n;
	int count;
	while(scanf("%d",&n)!=EOF)
	{
		count=calcu(n);
		printf("%d\n",count);
	}
	return 0;
}
